﻿Imports System.Web

Public Class CPushUpgradeClient_Config : Inherits CClient_Config

#Region "Constants"
	Public Const DEFAULT_IGNORES As String = CFolderHash.IGNORE_EXTENSIONS_AS_STRING & ",.xml,.pdb,.refresh,.pfx,.cer,.proto.gz,.log"

	Public Const COMMON_PREFIX As String = "PushUpgrade."

    Private Const KEY_ExtensionsToIgnore As String = "ExtensionsToIgnore"

    Private Shared PREFIXED_ExtensionsToIgnore As String = COMMON_PREFIX & KEY_ExtensionsToIgnore


    Public Shared ReadOnly SELF_FOLDER As String = GetSelfFolder()
    Private Shared Function GetSelfFolder() As String
        Dim c = HttpContext.Current
        If Not IsNothing(c) Then
            If Not IsNothing(c.Server) Then Return c.Server.MapPath("~/")
        End If
        Return My.Application.Info.DirectoryPath & "\"
    End Function
#End Region

#Region "Overrides (Prefix, Defaults)"
    Protected Overrides ReadOnly Property KEY_CommonPrefix As String
        Get
            Return COMMON_PREFIX
        End Get
    End Property
#End Region

#Region "Config settings (write first time)"
	Public Function WriteConfigSetting_ExtensionsToIgnore(Optional value As String = DEFAULT_IGNORES, Optional overwrite As Boolean = True) As Boolean
		Return WriteConfigSetting(KEY_ExtensionsToIgnore, value, overwrite)
	End Function
#End Region


	'New Config settings
	Public ReadOnly ExtensionsToIgnore_AsArray As String() = CUtilities.StringToListStr(ExtensionsToIgnore).ToArray()
    Public ReadOnly Property ExtensionsToIgnore As String
        Get
            Return Config_(PREFIXED_ExtensionsToIgnore, KEY_ExtensionsToIgnore, DEFAULT_IGNORES)
        End Get
    End Property
    Public ReadOnly Property Filter As CFilter
        Get
            Return New CFilter(ExtensionsToIgnore, True)
        End Get
    End Property

#Region "Singleton (Shared access to member variables)"
    Private Shared m_shared As New CPushUpgradeClient_Config
    Public Shared Shadows ReadOnly Property [Shared] As CPushUpgradeClient_Config
        Get
            Return m_shared
        End Get
    End Property
#End Region

End Class
